const path = require('path');
const fs = require('fs');
module.exports = app => {
  const exports = {};

  exports.cluster = {
    listen: {
      port: 7002,
      hostname: '0.0.0.0',
    },
  };

  exports.siteFile = {
    '/favicon.ico': fs.readFileSync(
      path.join(app.baseDir, 'app/web/asset/images/favicon.ico')),
  };

  exports.view = {
    cache: false,
  };

  exports.vuessr = {
    layout: path.join(app.baseDir, 'app/web/view/layout.html'),
    renderOptions: {
      basedir: path.join(app.baseDir, 'app/view'),
    },
  };

  exports.logger = {
    consoleLevel: 'DEBUG',
    dir: path.join(app.baseDir, 'logs'),
  };

  exports.keys = '';

  exports.middleware = ['access'];

  exports.sequelize = {
    dialect: 'mysql', // support: mysql, mariadb, postgres, mssql

    pool: {
      max: 100,
      min: 0,
      idle: 20000,
      acquire: 20000,
    },
    timezone: '+08:00',
  };

  exports.io = {
    namespace: {
      '/': {
        connectionMiddleware: ['auth'],
      },
    },
  };

  exports.spiderClient = {
    codeUrl: '',
    socketUrl: '',
  };

  return exports;
};
